﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;
using System.Data.SqlClient;

namespace ElingOA6_DSJCJ.DAL
{
    /// <summary>
    /// 问卷答案选择项 数据类
    /// </summary>
    public class PaperAnswerOption
    {
        public PaperAnswerOption()
        {
        }

        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-09-12</date>
        /// </summary>
        public DataSet GetList(decimal paperTopicId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select FPaperTopicId,FAnswerNo,FAnswerContent,FIsRestsAnswer,FRestsAnswerCount ");
            strSql.Append(" FROM t_PaperAnswerOption ");
            strSql.Append(" WHERE FPaperTopicId=@FPaperTopicId");
            strSql.Append(" order by FAnswerNo");
            SqlParameter[] parameters = {
					new SqlParameter("@FPaperTopicId", SqlDbType.Decimal,9)
					};
            parameters[0].Value = paperTopicId;

            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 得到一个对象实体
        /// <creator>wangl</creator>
        /// <date>2013-09-12</date>
        /// </summary>
        public ElingOA6_DSJCJ.Model.PaperAnswerOption DataRowToModel(DataRow row)
        {
            ElingOA6_DSJCJ.Model.PaperAnswerOption model = new ElingOA6_DSJCJ.Model.PaperAnswerOption();
            if (row != null)
            {
                if (row["FPaperTopicId"] != null && row["FPaperTopicId"].ToString() != "")
                {
                    model.FPaperTopicId = decimal.Parse(row["FPaperTopicId"].ToString());
                }
                if (row["FAnswerNo"] != null)
                {
                    model.FAnswerNo = row["FAnswerNo"].ToString();
                }
                if (row["FAnswerContent"] != null)
                {
                    model.FAnswerContent = row["FAnswerContent"].ToString();
                }
                if (row["FIsRestsAnswer"] != null)
                {
                    model.FIsRestsAnswer = row["FIsRestsAnswer"].ToString();
                }
                if (row["FRestsAnswerCount"] != null && row["FRestsAnswerCount"].ToString() != "")
                {
                    model.FRestsAnswerCount = int.Parse(row["FRestsAnswerCount"].ToString());
                }
            }
            return model;
        }

    }
}
